app.controller('brandController' ,function($scope,$controller,brandService){
	$controller('baseController',{$scope:$scope})
	
	$scope.findAll = function() {
		brandService.findAll().success(
			function(response) {
				$scope.list = response;
			}
		);
	}
	
	$scope.findPage = function(page,rows) {
		brandService.findPage(page,rows).success(
			function(response){
				$scope.list = response.rows;
				$scope.paginationConf.totalItems = response.total;
			}		
		);
	}
	
	$scope.save = function() {
		var methodName = "add";
		if($scope.entity.id!=null) {
			methodName='update';
		}
		brandService.save(methodName,$scope.entity).success(
			function(response) {
				if(response.success) {
					$scope.reloadList();
				} else {
					alert($scope.message);
				}
			}	
		);
	}
	
	$scope.findOne = function(id) {
		brandService.findOne(id).success(
			function(response) {
				$scope.entity = response;
			}	
		);
	}
	
	$scope.dele = function() {
		brandService.dele($scope.selectIds).success(
			function(response){
				if(response.success) {
					$scope.reloadList(); 					
				}
			}	
		);
	}
	$scope.searchEntity={};
	$scope.search=function(page,rows){		
		brandService.search(page,rows,$scope.searchEntity).success(
			function(response){
				$scope.list=response.rows;	
				$scope.paginationConf.totalItems=response.total;//更新总记录数
			}			
		);
	}

});